package org.enwey.icarenew.Fragment.BaseFragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;

import org.enwey.icarenew.R;


/**
 * Created by enwey on 2014/11/20.
 */
public abstract class BaseFragment extends android.support.v4.app.Fragment {
    private FrameLayout mContentLayout;
    private View mRootView;
    private RelativeLayout mNoData;
    private RelativeLayout mLoading;
    private String styleId;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mRootView = inflater.inflate(R.layout.fragment_base, container, false);
        findView();
        setContentView(LayoutInflater.from(getActivity()), mContentLayout);
        super.onCreateView(inflater, container, savedInstanceState);
        return mRootView;
    }

    private void findView() {
        mContentLayout = (FrameLayout) mRootView.findViewById(R.id.fragment_Base_content);
        mNoData = (RelativeLayout) mRootView.findViewById(R.id.fragment_base_noData);
        mLoading = (RelativeLayout) mRootView.findViewById(R.id.fragment_base_loading);
    }

    public void hideFragment() {

    }

    public void showFragment() {

    }

    public void setStyleId(String styleId) {
        this.styleId = styleId;
    }

    public String getStyleId() {
        return styleId;
    }

    // 显示加载数据
    public void showLoading() {
        mLoading.setVisibility(View.VISIBLE);
    }

    // 隐藏加载数据
    public void hideLoading() {
        mLoading.setVisibility(View.GONE);
    }

    // 显示没有数据
    public void showNoData() {
        mNoData.setVisibility(View.VISIBLE);
    }

    // 隐藏没有数据
    public void hideNoData() {
        mNoData.setVisibility(View.GONE);
    }

    public abstract void setContentView(LayoutInflater inflater,
                                        ViewGroup mLayerContextView);
}
